package com.example.user.service;
import com.example.event.ModuleEvent;
import com.example.model.entity.user.User;
import com.example.spi.ModuleService;
import org.springframework.stereotype.Component;

@Component // 让Spring管理这个Bean
public class UserModuleService implements ModuleService {
    @Override
    public String getName() {
        return "UserModule";
    }

    @Override
    public void execute() {
        System.out.println("用户模块执行操作");
    }

    @Override
    public boolean supports(ModuleEvent event) {
        // 判断是否支持处理该事件
        return event.getPayload() instanceof User;
    }

    @Override
    public void handleEvent(ModuleEvent event) {
        User user = (User) event.getPayload();
        System.out.println("用户模块处理事件: " + user.getName());
        // 处理用户相关逻辑
        System.out.println("处理用户相关逻辑");
    }
}